public class Pthread_Demo {
    public static void main(String[] args) throws InterruptedException {
        Mythread mythread = new Mythread();
        mythread.start();
        int i = 1;
        while(true){
            System.out.println(i);
            Thread.sleep(1000);
        }
    }
}
class Mythread extends Thread {
    public Mythread() {}
    public Mythread(String name) {
        super(name);
    }
    @Override
    public void run() {
        int i = 1;
        while (i>0) {
            System.out.println(getName());
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
